//
//  CityInfo.swift
//  AirlineReservation
//
//  Created by Kevin on 2020/1/25.
//  Copyright © 2020 Kevin. All rights reserved.
//

import UIKit

class CityInfo: NSObject {
    
    // 单例
    static let shareInstance:CityInfo = {
        return CityInfo()
    }()

    @objc var title:String?
    @objc var citys:Array<String>?
    
    override init() {
        
    }
    
    init(dict:[String:Any]) {
        super.init()
        setValuesForKeys(dict)
    }
    
    override func setValue(_ value: Any?, forUndefinedKey key: String) {
        
    }
    
    func getCityInfo() -> [CityInfo] {
        guard let file = Bundle.main.path(forResource: "citys", ofType: "plist") else {
            return [CityInfo]()
        }
        guard let arrs = NSArray(contentsOfFile: file) else {
            return [CityInfo]()
        }
        var temp = [CityInfo]()
        for item in arrs {
            let bean = CityInfo(dict: item as! [String : Any])
            temp.append(bean)
        }
        return temp
    }
    
    override var description: String {
        return dictionaryWithValues(forKeys: ["title","citys"]).description
    }
}
